package com.example.customviewtest.clipImage;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.customviewtest.R;

public class ClipImageActivity extends AppCompatActivity implements View.OnClickListener {


    private String mPath;
    private ImageView mClip_img_img;
    private ClipRectangleView mClip_view;
    private ClipFiveStarView mClip_five_view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_clip_image);
        Intent intent = getIntent();
        mPath = intent.getStringExtra("Uri");
        findViewById(R.id.btn1).setOnClickListener(this);
        mClip_img_img = findViewById(R.id.clip_img_img);
        mClip_view = findViewById(R.id.clip_view);
        mClip_five_view = findViewById(R.id.clip_five_view);
        mClip_five_view.setImagePath(mPath);
        mClip_view.setImagePath(mPath);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn1:
                Bitmap clipBitmap = mClip_view.getClipBitmap();
                mClip_view.setVisibility(View.GONE);
                Glide.with(ClipImageActivity.this).load(clipBitmap).into(mClip_img_img);
                mClip_view.recycle();
                break;
        }
    }


}
